<template>
  <div>
    <template>
      <!--循环-->
      <template v-for="item in this.menuList">
        <el-submenu :disabled="item.disabled" :index="item.id+''" :key="item.id+''"
                    v-if="item.children.length>0">
          <template slot="title">
            <i :class="item.icon"></i>
            <span slot="title">{{item.menuName}}</span>
          </template>
          <MenuTree :menuList="item.children"></MenuTree>
        </el-submenu>
        <!--如果有子元素就展示-->
        <el-menu-item
          v-else
          :disabled="item.disable"
          :index="item.url+''"
          :route="item.url+''"
          @click="savePath(item.url)"
          :key="item.id">
          <i :class="item.icon"></i>
          <span slot="title">{{item.menuName}}</span>
        </el-menu-item>
      </template>


    </template>
  </div>
</template>

<script>
    export default {
        name: 'MenuTree',
        props: ['menuList'],
      methods:{
        //保存激活路径
        savePath(path) {
          window.sessionStorage.setItem("activePath", path);
          /*调用Mian.vue的activePath*/
          this.activePath = path;
        },
      },
      created(){

      }
    }
</script>

<style>
  .el-menu--collapse span, el-
  .el-menu--collapse ib.sumenu__icon-arrow {
    height: 0;
    width: 0;
    overflow: hidden;
    visibility: hidden;
    display: inline-block;
  }
</style>
